package com.weng.cloud.service8881.async.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @Author: weng
 * @Date: 2022/4/26
 * @Description: com.weng.cloud.service8881.async.conf
 */
@Configuration
public class TestAsyncTaskExecutorConfiguration {

    @Bean
    public Executor taskExecutor(){
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(3);
        executor.setMaxPoolSize(3);
        executor.setQueueCapacity(500);
        executor.setThreadNamePrefix("test-async-executor");
        executor.initialize();
        return executor;
    }
}
